import { observable, action } from 'mobx'
import { IMenu } from '../interfaces/IMenu';

class MenuStore {
  /**
   * 用户权限菜单
   */
  @observable menus?: IMenu[] = [];

  /**
   * 是否将菜单收起
   */
  @observable collapse: boolean = false;

  /**
   * 当前激活菜单
   */
  @observable activeMenuId: string = '';

  /**
  * 设置用户权限菜单
  * @param menus
  */
  @action
  setMenu(menus: IMenu[]) {
    this.menus = menus || [];
  }

  /**
   * 设置当前激活菜单
   * @param menuId
   */
  @action
  setActiveMenuId(menuId: string){
    this.activeMenuId = menuId || '';
  }

  /**
   * 收起账单菜单
   * @param flag
   */
  @action
  collapseMenu(flag: boolean){
    this.collapse = flag || false;
  }
}

export default new MenuStore();
